// createStore:方法执行生成store实例对象
import { createStore } from 'vuex'
import user from './modules/user'
import cart from './modules/cart'
// 导入插件
import createPersistedstate from 'vuex-persistedstate'
// import * as Cookies from 'js-cookie'
export default createStore({
  state: {
  },
  mutations: {
  },
  actions: {
  },
  // 组合模块
  modules: {
    user,
    cart
  },
  plugins: [
    createPersistedstate({
      // storage: {
      //   getItem: key => Cookies.get(key),
      //   setItem: (key, value) => Cookies.set(key, value, { expires: 7 }),
      //   removeItem: key => Cookies.remove(key)
      // },
      key: 'erabbit-client-pc-store', // 存入本地时采用的来做标识的key值 支持自定义的语义化
      paths: ['user', 'cart']// 想要把那个模块中的数据进行持久化自动同步 就把模块名写出来
    })
  ]

})
